﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using WjAutoConfigApp.Common;
using WjAutoConfigApp.Models;

namespace WjAutoConfigApp
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            //Application.Run(new TestForm());
            //CSVHelper.InitCSV("TEST.csv", 4000, 4000, "-1");
            Application.Run(new MainForm());
        }

        static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
        {
            try
            {
                MessageBox.Show("系统异常：" + e.ToString() + "\r\n" + e.Exception.Message);
                WaitWindowRotate.Hide();
            }
            catch (Exception ex)
            {
            }
        }

        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                Exception ex = e.ExceptionObject as Exception;
                if (ex != null)
                {
                    MessageBox.Show("系统异常：" + e.ToString() + "\r\n" + ex.Message);
                    WaitWindowRotate.Hide();
                }
            }
            catch
            {
            }
        }
    }
}
